package org.icosagon.core.character;

import org.icosagon.core.Definable;
import org.icosagon.core.character.traits.Skill;
import java.util.Vector;
import org.icosagon.core.character.traits.Feat;

/**
 *
 * @author Daniel Owens
 */
public class AbstractBase extends Definable {

    private Vector<Feat> feats = new Vector<Feat>();
    
    /** Alignments that this race can not be. */
    private Vector<String> languages = new Vector<String>();
    private Vector<Skill> skills = new Vector<Skill>(5, 5);
    private Vector<String> proficient = new Vector<String>();
    
    public void addLanguage(String lang) {
        lang = lang.trim();
        if(lang.equals("") || lang == null)
            return;
        this.languages.add(lang);
    }
    
    public Vector<String> getLanguages() {
        return this.languages;
    }

    /**
     * If you are adding a skill that already exists the previous value is replaced with the new value.
     */
    public void addSkill(Skill skill) {
        boolean exists = false;
        for(Skill s : this.skills) {
            if(s.getName().equals(skill.getName())) {
                s = skill;
                exists = true;
            }
        }
        if(exists == false)
            this.skills.add(skill);
    }

    /**
     * Finds the type of skill and returns the Skill of this class.
     * @param skill
     * @return
     */
    public Skill getSkill(Skill skill) {
        for(Skill s : this.skills) {
            if(s.getName().equals(skill.getName())) {
                return s;
            }
        }
        return null;
    }

    public Skill getSkill(String name) {
        for(Skill s : this.skills) {
            if(s.getName().equals(name)) {
                return s;
            }
        }
        return null;
    }
    
    public Vector<Skill> getSkills() {
        return this.skills;
    }
    
    public void addProficiency(String prof) {
        this.proficient.add(prof);
    }

    public void removeProficiency(String String) {
        this.proficient.remove(String);
    }
    
    public Vector<String> getProficiencies() {
        return this.proficient;
    }

    public Vector<Feat> getFeats() {
        return this.feats;
    }

    public void addFeat(Feat feat) {
        this.feats.add(feat);
    }

    public void removeFeat(Feat feat) {
        this.feats.remove(feat);
    }

    public void setFeats(Vector<Feat> feats) {
        this.feats = feats;
    }
}